<%@page import="java.util.Calendar"%>
<%@page import="util.ResourceHelper"%>
<link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.8.16.custom.css" />	
<script type="text/javascript" src="/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" >
$(function() {	
	var currentDate = new Date();
	var day = currentDate.getDate();
	var month = currentDate.getMonth()+1;
	var year = currentDate.getUTCFullYear();
	$("#myLink").attr("href", year + "/" + month + "/" + day);
	$("#date").change(function() {
		  day = $("#date").val() ;
		  $("#myLink").attr("href", year + "/" + month + "/" + day);
		});
	$("#month").change(function() {
		  month = $("#month").val();
		  $("#myLink").attr("href", year + "/" + month + "/" + day);
		});
	$("#year").change(function() {
		  year = $("#year").val();	 	  
		  $("#myLink").attr("href", year + "/" + month + "/" + day);
		});
	$( "#datepicker" ).datepicker({
		yearRange: "-30:+0",
		maxDate: "+0",
		dateFormat:"yy/mm/dd",
		defaultDate: "+1w",
		changeMonth: true,
		changeYear:true,
		numberOfMonths: 1,
		onSelect: function( selectedDate ) {							
			window.location ="/" + $("#datepicker").val();
		}		
	});
});
</script>
<%
	Calendar cal = Calendar.getInstance();
 	int day = cal.get(Calendar.DATE);
 	int month = cal.get(Calendar.MONTH);
 	month += 1;
 	int year = cal.get(Calendar.YEAR);
 	String date = year + "/" + month + "/" + day;
%>

<%-- <div class="box-item">
     <div class="box-item_inner">    
        <h3 class="heading"><a href="#"><%=ResourceHelper.getByAlias("tin-theo-ngay") %></a></h3>
		<div id="datepicker" align="center" style=""></div>   		
     </div>
</div> --%>
<div class="box-item">
	<div class="box-item_inner">    
		<h3 class="heading"><a href="#"><%=ResourceHelper.getByAlias("tin-theo-ngay") %></a></h3>
        <div class="find-by-date">								
			 <select id="date" name="date">
			 	<%
			 		for(int i = 1; i<32; i++){
			 			if(i==day){
			 				%>
			 					<option selected="selected" value="<%=i%>"><%=i %></option>
			 				<%
			 			}else{
			 			%>
			 				<option value="<%=i%>"><%=i %></option>
			 			<%}
			 		}
			 	%>                
             </select>             
             <select id="month" name="month">
                 <%
			 		for(int i = 1; i<13; i++){
			 			if(i==month){
			 				%>
			 					<option selected="selected" value="<%=i%>"><%=i %></option>
			 				<%
			 			}else{
			 			%>
			 				<option value="<%=i%>"><%=i %></option>
			 			<%}
			 		}
			 	%>         
             </select>             
             <select id="year" name="year">
                  <%
			 		for(int i = 1990; i<2013; i++){
			 			if(i==year){
			 				%>
			 					<option selected="selected" value="<%=i%>"><%=i %></option>
			 				<%
			 			}else{
			 			%>
			 				<option value="<%=i%>"><%=i %></option>
			 			<%}
			 		}
			 		%>         
             </select>
             <a id="myLink" href="<%=request.getContextPath()%>/<%=date%>"><%=ResourceHelper.getByAlias("tim-kiem") %></a>	
		</div>	
	</div>
</div> 